using System;
using System.ComponentModel;

using EMan.Interface.EntityEditing;

using TrueCode.Core;
using TrueCode.Core.Aspects;

namespace EMan.BL.EntityEditing
{
  public abstract class EntityProperty : IEntityProperty
  {
    private string _comment;
    private CommentType _commentType = CommentType.Normal;

    protected EntityProperty( [NotNull] string comment)
    {
      if( string.IsNullOrEmpty( comment ) ) throw new ArgumentNullException( "comment" );
      _comment = comment;
    }

    public CommentType CommentType
    {
      get { return _commentType; }
      set
      {
        if( _commentType != value )
        {
          _commentType = value;
          PropertyChanged.Raise( this, () => CommentType );
        }
      }
    }

    public string Comment
    {
      get { return _comment; }
      set
      {
        _comment = value;
        PropertyChanged.Raise( this, () => Comment );
      }
    }

    public abstract bool IsReadOnly { get; }
    public abstract object Value { get; set; }

    public void NotifyValueChanged()
    {
      PropertyChanged.Raise( this, () => Value );
    }

    #region Implementation of INotifyPropertyChanged
    public event PropertyChangedEventHandler PropertyChanged;
    #endregion
  }
}